<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="keywords" content="">
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" href="assets/images/favicon.png" type="image/png">
    <title></title>
    <link href="assets/css/icons.css" rel="stylesheet">
    <link href="assets/css/bootstrap.min.css" rel="stylesheet">
    <link href="assets/css/style.css" rel="stylesheet">
    <link href="assets/css/responsive.css" rel="stylesheet">

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>

    <![endif]-->


    <!--   <script src="vali/jquery.validate.js"></script>-->
    <!--   <script src="vali/jquery.validate.min.js"></script>-->
    <!--    <script src="vali/localization/messages_zh.min.js"></script>-->

    <!--    <script src="validation-1.19.2/jquery.validate.min.js"></script>
        <script src="validation-1.19.2/localization/messages_zh.min.js"></script>-->

</head>

<body>


<!--Start login Section-->
<section class="login-section">
    <div class="container">
        <div class="row">
            <div class="login-wrapper">
                <div class="login-inner">

                    <div class="logo">
                        <img src="assets/images/logo-dark.png" alt="logo"/>
                    </div>

                    <h2 class="header-title text-center">用户注册</h2>

                    <form id="from_register">

                        <div class="form-group">
                            用户名: <input type="text" class="form-control" id="userName" placeholder="userName"
                                        name="userName">
                        </div>

                        <div class="form-group">
                            密码: <input type="text" class="form-control" id="password" placeholder="password"
                                       name="password">
                        </div>

                        <div class="form-group">
                            邮箱: <input type="email" class="form-control" id="email" placeholder="email(请按邮箱方式填写)"
                                        name="email">
                        </div>

                        <div class="form-group">
                            年龄: <input type="number" class="form-control" id="age" placeholder="age(填写0到100之间数字)"
                                        name="age">
                        </div>


                        <div class="form-group">
                            手机号: <input type="text" class="form-control" id="phone" placeholder="请输入11位数字的手机号" name="phone">
                        </div>

                        <div class="d-block my-3">
                            <div class="custom-control custom-radio d-inline">
                                <input id="btn_man" name="radiob" type="radio" value="男" class="custom-control-input" checked="checked" required="required">
                                <label class="custom-control-label" for="btn_man">男性</label>
                            </div>
                            <div class="custom-control custom-radio d-inline">
                                <input id="btn_woman" name="radiob" type="radio" value="女" class="custom-control-input" required="required">
                                <label class="custom-control-label" for="btn_woman">女性</label>
                            </div>
                        </div>

                        <div class="form-group">
                            <input type="button" onclick="RegSubmit()" value="注册" class="btn btn-primary btn-block"/>
                        </div>

                        <div class="form-group text-center">
                            已经有账户? <a href="loginphone.html">手机登录 </a>
                            <a href="loginpass.html"> ||密码登录 </a>
                            <a href="index.html"> ||首页 </a>
                        </div>
                        <div class="form-group text-center">

                        </div>

                    </form>

                    <div class="copy-text">
                        <p class="m-0">2021 &copy; Meter admin</p>
                    </div>

                </div>
            </div>

        </div>
    </div>
</section>
<!--End login Section-->


<!--Begin core plugin -->
<script src="assets/js/jquery.min.js"></script>
<script src="assets/js/bootstrap.min.js"></script>
<script src="assets/plugins/moment/moment.js"></script>
<script src="assets/js/jquery.slimscroll.js "></script>
<script src="assets/js/jquery.nicescroll.js"></script>
<script src="assets/js/functions.js"></script>
<script src="assets/js/util/http-util.js"></script>
<!-- End core plugin -->


</body>

</html>

<script type="text/javascript">
    /*$(function () {
        init();
    })

    function init(){
        $("#from_register").validate(
            {
                rules:{
                    userName:{required:true},
                    password:{required:true},
                    phone:{required:true}
                },
                messages: {
                    userName: {
                        required: "用户名，请务必填写哦！",
                    },
                    password: {
                        required: "密码，请务必填写哦！",
                    },
                    phone: {
                        required: "手机号码，请务必填写哦！",
                    }
                }
            }
        );
    }*/

    function RegSubmit() {
        let userName = $("#userName").val();
        if(userName==""){
            alert("用户名不能为空")
            return false;
        }
        let phone = $("#phone").val();
        if(phone==""){
            alert("手机号不能为空")
            return false;
        }
        let password = $("#password").val();
        if(password==""){
            alert("密码不能为空")
            return false;
        }

        let email = $("#email").val();
        if(email==""){
            alert("邮箱不能为空")
            return false;
        }

        let age = $("#age").val();
        if(age==""){
            alert("年龄不能为空")
            return false;
        }

        let sex = $("input[type='radio']:checked").val();

        let url = "/register.do";
        let params = {
            userName: userName, phone: phone,
            password: password,email:email,
            age:age,sex:sex
        };
        doPost(url, params, function (json) {
            location.href = "loginphone.html";
            alert("注册成功，请登录");
        })
    }

</script>


